package ferp.android.widgets.buttons.suit;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import ferp.android.widgets.SuitView;
import ferp.android.widgets.buttons.BidShifter;
import ferp.android.widgets.buttons.TwoLayerButton;
import ferp.core.card.Card;
import ferp.core.game.Bid;
import ferp.core.game.Game;

/**
 * User: igorgok
 * Date: 12/30/13 12:25 PM
 */
public abstract class SuitButton extends TwoLayerButton implements BidShifter
{
  public SuitButton(Context context) {super(context);}
  public SuitButton(Context context, AttributeSet attrs) {super(context, attrs);}
  public SuitButton(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);}

  public void show(Game g, Bid bid)
  {
    setEnabled(getEnabledState(g, bid));

    suit.set(getSuitToShow(g, bid));
  }

  @Override
  protected View onCreateUpperLayer(Context context, AttributeSet attrs)
  {
    return (suit = new SuitView(context, 0.4f));
  }

  protected abstract boolean getEnabledState(Game g, Bid bid);
  protected abstract Card.Suit getSuitToShow(Game g, Bid bid);

  private SuitView suit;
}
